<template>
    <el-form label-width="120px" :model="ProjectPeoplePage" ref="UpdataProjectPeoplePage_refs" :rules="ProjectPeoplePageRules">
        <el-row>
            <el-col :span="11" :offset="1">
                <el-form-item label="类型">
                    <el-select v-model="ProjectPeoplePage.Type" @change="typechangeEvent" style="width: 100%">
                        <el-option :value="1" label="专职"></el-option>
                        <el-option :value="2" label="兼职"></el-option>
                    </el-select>
                </el-form-item>
            </el-col>
            <el-col :span="11">
                <el-form-item label="姓名" prop="Userid">
                    <el-select filterable v-model="ProjectPeoplePage.Userid" v-show="TypeOne" style="width: 100%">
                        <el-option v-for="v in $store.state.AllUsers" :value="v.Id" :label="v.UserName"></el-option>
                    </el-select>
                    <el-input v-show="TypeTwo" v-model="ProjectPeoplePage.UserName"></el-input>
                </el-form-item>
            </el-col>
        </el-row>
        <el-row v-show="TypeTwo">
            <el-col :span="11" :offset="1">
                <el-form-item label="年龄">
                    <el-input v-model="ProjectPeoplePage.Age"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="11">
                <el-form-item label="劳务费用">
                    <el-input v-model="ProjectPeoplePage.LaborCost"></el-input>
                </el-form-item>
            </el-col>
        </el-row>
        <el-row>
            <el-col :span="11" :offset="1">
                <el-form-item label="特殊技能">
                    <el-input v-model="ProjectPeoplePage.Skill"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="11">
                <el-form-item label="工作职责">
                    <el-input v-model="ProjectPeoplePage.WorkContent"></el-input>
                </el-form-item>
            </el-col>
        </el-row>
        <el-row>
            <el-col :span="22" :offset="1">
                <el-form-item label="工作周期">
                    <el-input v-model="ProjectPeoplePage.WorkCycle"></el-input>
                </el-form-item>
            </el-col>
        </el-row>
        <el-row>
            <el-col align="center">
                <el-button @click="UpdataProjectPeoplePageSubmit" type="success">修改</el-button>
            </el-col>
        </el-row>
    </el-form>
</template>

<script>
    export default {
        name: "UpdataProjectPeoplePage",
        props:{
            ProjectPeoplePage:{
                type:Object,
                required:true,
            }
        },
        data(){
            return{
                TypeOne:true,
                TypeTwo:false,
                ProjectPeoplePageRules:{
                    Userid: [{ required:true,message:'请选择人员',trigger:'change' }]
                },
            }
        },
        created() {
            this.Init()
        },
        watch:{
            ProjectPeoplePage:function () {
                this.Init()
            }
        },
        methods:{
            UpdataProjectPeoplePageSubmit(){
                this.$refs['UpdataProjectPeoplePage_refs'].validate((vali)=>{
                    if (vali){
                        this.$http.post('Project1/UpdateProjectPeople',{ projectPeople:this.ProjectPeoplePage }).then(res=>{
                            if (res.data.IsSuccess){
                                this.$message.success(res.data.Msg)
                                this.$parent.$parent.UpdataProjectPeoplePage_dialog.show=false
                            }else{
                                this.$message.warning(res.data.Msg)
                            }
                        })
                    }
                })
            },
            typechangeEvent(val){
                let _this = this
                switch (val) {
                    case 1:
                        _this.TypeOne=true
                        _this.TypeTwo=false
                        break;
                    case 2:
                        _this.TypeOne=false
                        _this.TypeTwo=true
                        break;
                }
            },
            //初始加载页面设置
            Init(){
                let _this = this
                switch (this.ProjectPeoplePage.Type) {
                    case 1:
                        _this.TypeOne=true
                        _this.TypeTwo=false
                        break;
                    case 2:
                        _this.TypeOne=false
                        _this.TypeTwo=true
                        break;
                }
            },
        },
    }
</script>

<style scoped>

</style>
